﻿using www.w3.org.Item2001.XMLSchema;

namespace Sidvall.CodeGenerator.DataObjects
{
	public class SchemaElement : SchemaItem
	{
		public element Item { get; set; }

        public override string ToString()
        {
            return this.Item.Content.name;
        }
    }

	public class SchemaElementCollection : System.Collections.ObjectModel.KeyedCollection<element, SchemaElement>
	{

		#region Business Members

		#region Add

		public void Add(schema parent, element item, string fileName)
		{
			SchemaElement value;

			if (parent == null)
				throw new System.ArgumentNullException("parent");
			if (item == null)
				throw new System.ArgumentNullException("item");
			if (Contains(item))
				return;

			value = new SchemaElement()
			{
				Item = item,
				Parent = parent,
				FileName = fileName
			};
			Add(value);
		}

		#endregion
		#region GetKeyForItem

		protected override element GetKeyForItem(SchemaElement item)
		{
			if (item == null)
				throw new System.ArgumentNullException("item");
			return item.Item;
		}

		#endregion

		#endregion
		#region Constructors

		public SchemaElementCollection()
		{
		}

		#endregion

	}
}
